<?php


namespace app\common\model\system;

use think\Model;
use think\model\concern\SoftDelete;

/**
 * @mixin \think\Model
 */
class Porder extends Model
{
    use SoftDelete;

    // 定义时间戳字段名
    protected $createTime = 'create_time';


    /**
     * 获取订单状态文本
     * @access      public
     * @param $filesize
     * @return      string
     */
    public function getStatusTextAttr($value, $order): string
    {
        $text = '状态错误';
        if ($order['type'] == 1) {
            switch ($order['status']) {
                case '1':
                    $text = '待发货';
                    break;
                case '2':
                    $text = '待收货';
                    break;
                case '3':
                    $text = '已完成';
                    break;
                case '4':
                    $text = '已取消';
                    break;
                default:
                    # code...
                    break;
            }
        }else{
            switch ($order['status']) {
                case '1':
                    $text = '待确认';
                    break;
                case '2':
                    $text = '待兑换';
                    break;
                case '3':
                    $text = '已完成';
                    break;
                case '4':
                    $text = '已取消';
                    break;
                default:
                    # code...
                    break;
            }
        }
        return $text;
    }
}
